<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

if (!function_exists('overViewFieldSearch')) {

    function overViewFieldSearch($searchData = array())
    {
        $CI = & get_instance();
        $loading = $CI->lang->line('Loading');
        $_field_search_attribute = array(
            'textsearch' => array('name' => 'textsearch', 'id' => 'frm-textsearch',
                'class' => 'span3', 'placeholder' => $CI->lang->line('Pls_enter_keyword'),
                'value' => set_value('textsearch', isset($searchData['textsearch']) ? $searchData['textsearch'] : '')
            ),
            'submit' => array('name' => 'btn-Search', 'class' => 'btn btn-primary', 'data-loading-text' => $loading,
                'id' => 'form-btnSearch', 'value' => $CI->lang->line('Search')),
            'reset' => array('name' => 'btn-Reset', 'class' => 'btn btn-primary', 'data-loading-text' => $loading,
                'id' => 'form-btnReset', 'value' => $CI->lang->line('Reset')),
        );

        return $_field_search_attribute;
    }

}

if (!function_exists('overViewFieldFilter')) {

    function overViewFieldFilter($filterData = array(), $filterSelected = 0)
    {
        $CI = & get_instance();
        $loading = $CI->lang->line('Loading');
        $_field_filter_attribute = array(
            'dropdown_filter' => array(
                'name' => 'function',
                'data' => $filterData,
                'selected' => $filterSelected,
                'extra' => "id='frm-ia-attribute-filter' class='span3'"
            ),
            'submit' => array('name' => 'btn-Filter', 'class' => 'btn btn-primary', 'data-loading-text' => $loading,
                'id' => 'form-btnSearch', 'value' => $CI->lang->line('Filter')),
            'reset' => array('name' => 'btn-Reset', 'class' => 'btn btn-primary', 'data-loading-text' => $loading,
                'id' => 'form-btnReset', 'value' => $CI->lang->line('Reset')),
        );

        return $_field_filter_attribute;
    }

}


//define field to generate form
if (!function_exists('overViewFieldForm')) {

    function overViewFieldForm($overview = array())
    {
        $CI = & get_instance();
        if (count($overview) && !empty($overview)) {

            $affaire = $overview->affaire;
            $seller_action = $overview->seller_action;
            $ia_action = $overview->ia_action;
            $other_support = $overview->other_support;
            $training = $overview->training;
        }

        $_field_form = array(
            'affaire' => array('name' => 'affaire', 'id' => 'frm-affaire',
                'class' => 'span3', 'placeholder' => $CI->lang->line('Pls_enter_attribute'),
                'value' => set_value('affaire', isset($affaire) ? $affaire : ''),
                'rows' => 3,
                'cols' => 5
            ),
            'seller_action' => array('name' => 'seller_action', 'id' => 'frm-seller_action',
                'class' => 'span3', 'placeholder' => $CI->lang->line('Pls_enter_attribute'),
                'value' => set_value('seller_action', isset($seller_action) ? $seller_action : ''),
                'rows' => 3,
                'cols' => 5
            ),
            'ia_action' => array('name' => 'ia_action', 'id' => 'frm-ia_action',
                'class' => 'span3', 'placeholder' => $CI->lang->line('Pls_enter_attribute'),
                'value' => set_value('ia_action', isset($ia_action) ? $ia_action : ''),
                'rows' => 3,
                'cols' => 5
            ),
            'other_support' => array('name' => 'other_support', 'id' => 'frm-other_support',
                'class' => 'span3', 'placeholder' => $CI->lang->line('Pls_enter_attribute'),
                'value' => set_value('other_support', isset($other_support) ? $other_support : ''),
                'rows' => 3,
                'cols' => 5
            ),
            'training' => array('name' => 'training', 'id' => 'frm-training',
                'class' => 'span3', 'placeholder' => $CI->lang->line('Pls_enter_attribute'),
                'value' => set_value('training', isset($training) ? $training : ''),
                'rows' => 3,
                'cols' => 5
            ),
            'submit' => array('class' => 'btn btn-primary', 'data-loading-text' => $CI->lang->line('Loading'),
                'id' => 'form-submit', 'value' => $CI->lang->line('Save')),
        );

        return $_field_form;
    }

}

//define field to validate form
if (!function_exists('overViewFieldValidate')) {

    function overViewFieldValidate()
    {
        $CI = & get_instance();
        $_field_validate = array(
            array(
                'field' => 'affaire',
                'label' => $CI->lang->line('affaire'),
                'rules' => 'trim|xss_clean'
            ),
            array(
                'field' => 'seller_action',
                'label' => $CI->lang->line('seller_action'),
                'rules' => 'trim|xss_clean'
            ),
            array(
                'field' => 'ia_action',
                'label' => $CI->lang->line('ia_action'),
                'rules' => 'trim|xss_clean'
            ),
            array(
                'field' => 'other_support',
                'label' => $CI->lang->line('other_support'),
                'rules' => 'trim|xss_clean'
            ),
            array(
                'field' => 'training',
                'label' => $CI->lang->line('training'),
                'rules' => 'trim|xss_clean'
            ),
        );
        return $_field_validate;
    }

}